package demo.dcs.util;

import demo.dcs.vo.PlayStatTypeEnum;
import org.apache.commons.lang.StringUtils;


/**
 * @author mandy.hu
 *
 */
public class PlayStatTypeConvertUtil {


	public static String getConvertedPlayStatType_MONITOR_DB_RESPONSE_TIME_CALLER(PlayStatTypeEnum playStatTypeEnum, String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_DB_RESPONSE_TIME_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_DB_RESPONSE_TIME_CALLER+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_DB_RESPONSE_TIME_CALLEE(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_DB_RESPONSE_TIME_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_DB_RESPONSE_TIME_CALLEE+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_DB_CALLEE(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_DB_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_DB_CALLEE+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_DB_CALLER(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_DB_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_DB_CALLER+"__" + app;
	}


	public static String getConvertedPlayStatType_MONITOR_REDIS_RESPONSE_TIME_CALLER(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_REDIS_RESPONSE_TIME_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_REDIS_RESPONSE_TIME_CALLER+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_REDIS_RESPONSE_TIME_CALLEE(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_REDIS_RESPONSE_TIME_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_REDIS_RESPONSE_TIME_CALLEE+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_REDIS_CALLEE(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_REDIS_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_REDIS_CALLEE+"__" + app;
	}

	public static String getConvertedPlayStatType_MONITOR_REDIS_CALLER(PlayStatTypeEnum playStatTypeEnum,String app) {
		if (StringUtils.isBlank(app)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_REDIS_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_REDIS_CALLER+"__" + app;
	}
	
	public static String getConvertedPlayStatType_MONITOR_RESPONSE_TIME_APP_API_CALLER(PlayStatTypeEnum playStatTypeEnum,String callerApp) {
		if (StringUtils.isBlank(callerApp)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_RESPONSE_TIME_APP_API_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_RESPONSE_TIME_APP_API_CALLER+"__" + callerApp;
	
	}
	public static String getConvertedPlayStatType_MONITOR_RESPONSE_TIME_APP_API_CALLEE(PlayStatTypeEnum playStatTypeEnum,String calleeApp) {
		if (StringUtils.isBlank(calleeApp)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_RESPONSE_TIME_APP_API_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_RESPONSE_TIME_APP_API_CALLEE+"__" + calleeApp;
	}

	public static String getConvertedPlayStatType_MONITOR_SERVER_LOAD_APP_API_CALLER(PlayStatTypeEnum playStatTypeEnum,String callerApp) {
		if (StringUtils.isBlank(callerApp)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_SERVER_LOAD_APP_API_CALLER.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_SERVER_LOAD_APP_API_CALLER+"__" + callerApp;
	
	}
	public static String getConvertedPlayStatType_MONITOR_SERVER_LOAD_APP_API_CALLEE(PlayStatTypeEnum playStatTypeEnum,String calleeApp) {
		if (StringUtils.isBlank(calleeApp)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_SERVER_LOAD_APP_API_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_SERVER_LOAD_APP_API_CALLEE + "__" + calleeApp;
	}
	
    public static String getConvertedPlayStatType_MONITOR_RESPONSE_TIME_HOST_HOST(PlayStatTypeEnum playStatTypeEnum,String callerApp,String calleeApp,String callerApi,String calleeApi) {
    	if (StringUtils.isBlank(callerApp) || StringUtils.isBlank(calleeApp)|| StringUtils.isBlank(callerApi) || StringUtils.isBlank(calleeApi)) {
			return null;
		}
    	if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_RESPONSE_TIME_HOST_HOST.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_RESPONSE_TIME_HOST_HOST+"__" + callerApp+"__"+callerApi+"__"+calleeApp+"__"+calleeApi;
	}
    public static String getConvertedPlayStatType_MONITOR_SERVER_LOAD_HOST_HOST(PlayStatTypeEnum playStatTypeEnum,String callerApp,String calleeApp,String callerApi,String calleeApi) {
    	if (StringUtils.isBlank(callerApp) || StringUtils.isBlank(calleeApp)|| StringUtils.isBlank(callerApi) || StringUtils.isBlank(calleeApi)) {
			return null;
		}
    	if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.MONITOR_SERVER_LOAD_HOST_HOST.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.MONITOR_SERVER_LOAD_HOST_HOST +"__" + callerApp+"__"+callerApi+"__"+calleeApp+"__"+calleeApi;
	}
    
	public static String getConvertedPlayStatType_SAMPLE_COMPENSATION_CALLEE_TAGS_CALLEE(PlayStatTypeEnum playStatTypeEnum,String calleeApp) {
		if (StringUtils.isBlank(calleeApp)) {
			return null;
		}
		if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.SAMPLE_COMPENSATION_CALLEE_TAGS_CALLEE.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.SAMPLE_COMPENSATION_CALLEE_TAGS_CALLEE + "__" + calleeApp;
	}
	
    public static String getConvertedPlayStatType_SAMPLE_COMPENSATION_HOST_HOST(PlayStatTypeEnum playStatTypeEnum,String callerApp,String calleeApp,String callerApi,String calleeApi) {
    	if (StringUtils.isBlank(callerApp) || StringUtils.isBlank(calleeApp)|| StringUtils.isBlank(callerApi) || StringUtils.isBlank(calleeApi)) {
			return null;
		}
    	if (!StringUtils.equals(playStatTypeEnum.getMetric(), PlayStatTypeEnum.SAMPLE_COMPENSATION_HOST_HOST.getMetric())) {
			return null;
		}
		return PlayStatTypeEnum.SAMPLE_COMPENSATION_HOST_HOST+"__" + callerApp+"__"+callerApi+"__"+calleeApp+"__"+calleeApi;
	}

}
